package com.mszlu.rpc.proxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

public class MsRpcClientProxy implements InvocationHandler {

    public  MsRpcClientProxy() {
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        //实现业务，发送网络请求，获取结果，返回
        System.out.println("rpc 服务消费方发起了调用");



        return null;
    }

    /**
     * 通过接口生成代理类
     * @param interfaceClass
     * @param <T>
     * @return
     */
    public <T> T getProxy(Class<T> interfaceClass) {
        return (T) Proxy.newProxyInstance(interfaceClass.getClassLoader(), new Class<?>[]{interfaceClass},this);
    }
}
